from sqlalchemy.ext.asyncio import AsyncSession as Session
from app.schemas.xm.xm_buy_order import XMBuyOrderCreate
from app.models.xm.xm_buy_order import XMBuyOrder

async def create_buy_order(
    session: Session,
    order: XMBuyOrderCreate,
) -> XMBuyOrder:
    """创建购买订单"""
    db_order = XMBuyOrder(**order.model_dump())
    session.add(db_order)
    await session.commit()
    await session.refresh(db_order)
    return db_order